function limparPadrao(campo) {
        if(campo.name ==  "senhaconf" || campo.name == "senha")
         {
             if (campo.value == campo.defaultValue ) 
             {
                 campo.value = "";        
             }
             campo.type = "password";
         }
         else
         {
             if (campo.value == campo.defaultValue ) 
             {
                 campo.value = "";        
             }
         }
     
 }
 function escreverPadrao(campo) {
          
     if(campo.name ==  "senhaconf" || campo.name == "senha")
         {
            if (campo.value == "") 
            {
                 campo.value = campo.defaultValue;
                 campo.type = "text";
            }
         }
         else
         {
             if (campo.value == "")
             { 
                 campo.value = campo.defaultValue;
             }
         }
     
 }
 
 var isNN = (navigator.appName.indexOf("Netscape")!=-1);
 function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
 }
 
 function containsElement(arr, ele) {
     var found = false, index = 0;
     while(!found && index < arr.length)
     if(arr[index] == ele)
         found = true;
     else
        index++;
     return found;
 }
 
 function getIndex(input) {
     var index = -1, i = 0, found = false;
     while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
     }
     return true;
 }

 function confirma() {
	
	if (confirm("Deseja Excluir?")){
            return true;
	}
	else{
            return false;
	}
}


// Progresso do campo descricao da dica
function progreso_tecla(obj) {
    
    var max=250;
    var ancho=300;
    var progreso = document.getElementById("progreso");

  if (obj.value.length < max)
  {
    progreso.style.backgroundColor = "#FFFFFF";
    progreso.style.backgroundImage = "url(http://localhost/hintweek/img/textarea.png)";
    progreso.style.color = "#000000";
    var pos = ancho-parseInt((ancho*parseInt(obj.value.length))/250);
    progreso.style.backgroundPosition = "-"+pos+"px 0px";

  }
  else
  {
    progreso.style.backgroundColor = "#CC0000";
    progreso.style.backgroundImage = "url()";
    progreso.style.color = "#FFFFFF";
    
  }
  progreso.innerHTML = "("+obj.value.length+" / "+max+")";
}  
    
function abrirPag(valor, valor2)
{
    var url = valor;
    var id  = valor2;

    xmlRequest.onreadystatechange = function()
    {
        if (xmlRequest.readyState == 4)
        {
            document.getElementById(id).innerHTML = xmlRequest.responseText;
        }
                
    };
    
    xmlRequest.open("GET",url,true);
    xmlRequest.send(null);

    if (xmlRequest.readyState == 1) 
    {
        document.getElementById(id).innerHTML =  "<img src='http://localhost/hintweek/img/ajax-loader.gif'>";
    }
    
    return url;
}

//funcao Show/hide div
function toggle(id) 
{
    var state = document.getElementById(id).style.display;
        
    if (state == 'block') 
    {
        document.getElementById(id).style.display = 'none';
    } else {
        document.getElementById(id).style.display = 'block';
    }
}
